package com.wwp.tbshop.presenter;

import android.util.Log;

import com.wwp.tbshop.activity.HotProductsActivity;
import com.wwp.tbshop.model.bean.BaseBean;
import com.wwp.tbshop.model.bean.HotProductBean;

import java.util.List;

import retrofit2.Call;


/**
 * Created by ${wenping} on 6/16/2017.
 */

public class HotProductPresenter extends BasePresenter{
    private static final String TAG = "HotProductPresenter";
    private HotProductsActivity mHotProductsActivity;

    public void loadHotProductInfo() {
        Call<HotProductBean> hotProductBeanCall = mApiService.getHotProducts("1", "10", "saleDown");
        hotProductBeanCall.enqueue(mCallback);
    }

    public HotProductPresenter(HotProductsActivity hotProductsActivity) {
        mHotProductsActivity = hotProductsActivity;
    }
    boolean openLog = false;
    @Override
    protected void onServerBug(int code) {
        if (openLog) {
            Log.e(TAG, "onServerBug ");
        }
    }

    @Override
    protected void onConnectError(String message) {
        if (openLog) {
            Log.e(TAG, "onConnectError ");
        }
    }

    @Override
    protected void onSuccess(BaseBean bean) {
        if (openLog){
            Log.e(TAG, "onSuccess ");
        }
        HotProductBean hotProductBean = (HotProductBean) bean;
        if (hotProductBean!=null){
            List<HotProductBean.ProductListBean> productListBeanList = hotProductBean.getProductList();
            mHotProductsActivity.onHotProductSuccess(productListBeanList);
        }
    }
}
